Skip to main content

All Questions

1vote
1answer
397views

Update specific value of one file by values in another text file

I have a text files in ascii format and wanted to replace a specific value by value saved in another text file. consider a file of name text_1. . . . 50.asc 5 columns, 4 rows sample data in a file ...
Muhammad Umar's user avatar
2votes
3answers
193views

Find and Replace Everything Before a String of Text

I have a large list of IP addresses (most are IPv4, but a few are IPv6), followed by a space and then a domain name, followed by another space and the same domain name with "www." in front of it. Each ...
Eric Bradshaw's user avatar
11votes
2answers
34kviews

Editing a child JSON element value with jq

I'm trying to use jq in order to change a child's value. For instance, I want to change the value of "test2" from ["yo", "bye"] to ["hi"]. { "title": "hello", "body": { "test1": 123, ...
Maboo's user avatar
0votes
2answers
1kviews

Use multiple commands in sed to insert text after string with special characters

I am having a little trouble trying to do a search and replace using sed in a config file. I want to use multiple commands using the -e option to do the following. Step 1: find the first occurrence ...
ausip's user avatar
2votes
1answer
1kviews

Replace spaces and tabs at the end of the line in all files

I need to replace all unwanted spaces in all files from the current directory and from directories from the current directory (recursive search). I define the unwanted spaces the spaces and tabs that ...
Ionică Bizău's user avatar
6votes
5answers
23kviews

Use sed to find whole word and replace

I have the following block of text in a file: test3.legacy test4.legacy test3 test3.kami I only want to search for test3 as a whole and replace it with nothing. Unfortunately, all my attempts have ...
maGz's user avatar
  • 993
1vote
2answers
885views

How to find and replace files contents that match a pattern?

Suppose we have a folder named Project. I would like find each file in the folder that contains the pattern &$ at the function call. For example should replace: AnyFunction(&$arg); with ...
GarouDan's user avatar
2votes
1answer
366views

Replace "<?php print t('Blabla'); ?>" to be "Blabla"

Lets say in file.php, there is lots of php print text: <?php print t('Blabla'); ?>, <?php print t('Text Here'); ?>, etc. What I need is to remove <?php print t(' and '); ?> of the ...
apasajja's user avatar
2votes
2answers
6kviews

regex replace text in xml file within node from the command line

I have an XML file and I would like to replace everything that is between the open and closing tag within multiple instances of the g:gtin node with nothing. Is this possible from the command line, ...
crmpicco's user avatar
5votes
4answers
4kviews

Replace whole line in a file from command-line

I have a text file which has some contents similar to this: # General information about the project. project = u'Py6S' copyright = u'2012, Robin Wilson' # The version info for the project you're ...
robintw's user avatar
44votes
12answers
91kviews

How can I "cat" a file and remove commented lines?

I'd like to know if there is a way that I could cat file like php.ini and remove all lines starting with ; For example, if the file contained this: ; - Show all errors, except for notices ; ;...
cwd's user avatar
  • 46.7k

close